package com.jusda.config;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author:y022 22/04/2022 21:23
 * @description: 向容器注册一个producer实例, 这样在使用注解注入这个实例时，不需要在手动启动生产者服务。
 */
//@Configuration
public class ProducerConfiguration {
    @Value("${spring.application.name}")
    private String producerGroup;

    @Value("${rocketmq.name-server}")
    private String nameServer;

//    @Bean
    public DefaultMQProducer defaultMQproducer() {
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer(producerGroup);
        defaultMQProducer.setNamesrvAddr(nameServer);
        return defaultMQProducer;
    }
}
